<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增【请填写功能名称】')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-address-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">详细地址：</label>
                <div class="col-sm-8" style="margin-top: 20px;margin-left: 250px">
                    <p>
                        省/直辖市:<select id="provience" name="addressDesc" onchange="findMore2(this.value)" >
                                    <option >--请选择--</option>
                                 </select>
                    </p>
                    <p>
                        市/市辖区:<select id="city" name="addressDesc" onchange="findMore3(this.value)">
                                    <option>--请选择--</option>
                                 </select>
                    </p>
                    <p>
                        县/区:<select id="county" name="addressDesc" onchange="findMore4(this.value)">
                                <option>--请选择--</option>
                              </select>
                    </p>
                    <p>
                        镇:<select id="town" name="addressDesc" >
                                <option>--请选择--</option>
                           </select>
                    </p>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否送货：</label>
                <div class="col-sm-8" style="margin-left: 250px">
                    <div class="radio-box">
                        <input type="radio" name="addressStatus" value="是">
                        <label th:for="addressStatus" th:text="是"></label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" name="addressStatus" value="否">
                        <label th:for="addressStatus" th:text="否"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "system/address"
        $("#form-address-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-address-add').serialize());
            }
        }

        $(function () {
            findMore();
        })
        function findMore() {
            $.ajax({
                type:"post",
                url:"findMoreLer",
                data:{parentID:1},
                success:function (result) {
                    for (var i in result){
                        $("#provience").append("<option value='"+result[i].id+"'>"+result[i].name+"</option>")
                    }
                }
            })
        }
        function findMore2(parentID) {
            $.ajax({
                type:"post",
                url:"findMoreLer",
                data:{parentID:parentID},
                success:function (result) {
                    $("#city").html("<option>--请选择--</option>")
                    for (var i in result){
                        $("#city").append("<option value='"+result[i].id+"'>"+result[i].name+"</option>")
                    }
                }
            })
        }
        function findMore3(parentID) {
            $.ajax({
                type:"post",
                url:"findMoreLer",
                data:{parentID:parentID},
                success:function (result) {
                    $("#county").html("<option>--请选择--</option>")
                    for (var i in result){
                        $("#county").append("<option value='"+result[i].id+"'>"+result[i].name+"</option>")
                    }
                }
            })
        }
        function findMore4(parentID) {
            $.ajax({
                type:"post",
                url:"findMoreLer",
                data:{parentID:parentID},
                success:function (result) {
                    $("#town").html("<option>--请选择--</option>")
                    for (var i in result){
                        $("#town").append("<option value='"+result[i].id+"'>"+result[i].name+"</option>")
                    }
                }
            })
        }


        var pro = $("#provience option:selected").text();;
        console.log(pro);


    </script>
</body>
</html>